package org.anderes.playground.example;

public class PhoneNumber {

    private int areaCode;
    private int prefix;
    private int lineNumber;
    
    private PhoneNumber(int areaCode, int prefix, int lineNumber) {
        super();
        this.areaCode = areaCode;
        this.prefix = prefix;
        this.lineNumber = lineNumber;
    }
    
    /**
     * Returns the string representation o this phone number. The string
     * consists of fourteen characters whose format is "(XXX) YYY-ZZZZ",
     * where XXX is the area code, YYY is the prefix, and ZZZZ is the
     * line number. (Each of the capital letters represents a single
     * decimal digit.)
     * </p>
     * If any of the three parts of this phone number ist too small
     * to fill up its field, the field is padded with leading zeros.
     * For example, if the value of the line number ist 123, the last
     * four characters of the string representation will be "0123".
     * </p>
     * Note that there is a single space seperating the closing parenthesis
     * after the area code from the first digit of the prefix.
     */
    @Override
    public String toString() {
        return String.format("(%03d) %03d-%04d", areaCode, prefix, lineNumber);
    }
    
    public static void main(String[] args) {
        System.out.println(new PhoneNumber(041, 071, 1234).toString());
    }
    
}
